package com.yys.springcloud.service.feign;

import com.yys.springcloud.entities.CommonResult;
import com.yys.springcloud.entities.Payment;
import com.yys.springcloud.service.feign.fallback.PaymentFallbackService;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;

/**
 * @program: cloudalibaba2021
 * @description:
 * @author: Mr.Wu
 * @create: 2021-06-21 15:15
 **/
@Component // 记得加到spring容器中
//服务端配置的服务名, 失败会调用PaymentFallbackService.class的同名方法
@FeignClient(value = "cloud-nacos-payment",fallback = PaymentFallbackService.class)
public interface PaymentFeignService {

    //使用feign就可以向调用controller一样远程调用服务
    @GetMapping("/payment/get/{id}")
    CommonResult<Payment> getPaymentId(@PathVariable("id") Long id);
}
